import { computed } from "vue";

export const useModel = (props: any, emit: any) => {
  return computed(() => {
    const proxy = new Proxy(props.modelValue, {
      get(target, key) {
        return Reflect.get(target, key);
      },
      set(target, key, value) {
        emit("update:modelValue", {
          ...target,
          [key]: value,
        });
        return true;
      },
    });
    return proxy;
  });
};
